#include "urlinfoitemwidget.h"
#include "ui_urlinfoitemwidget.h"

UrlInfoItemWidget::UrlInfoItemWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::UrlInfoItemWidget)
{
    ui->setupUi(this);
}

UrlInfoItemWidget::~UrlInfoItemWidget()
{
    delete ui;
}

// 设置标签url
void UrlInfoItemWidget::setUrlInfo(UrlInfo urlInfo)
{
    this->ui->name->setText(QString(urlInfo.name.c_str()));
    this->ui->tag->setText(QString(urlInfo.tag.c_str()));
    this->ui->link->setText(QString(urlInfo.url.c_str()));
}

// 设置历史记录url
void UrlInfoItemWidget::setHistoryInfo(UrlInfo urlInfo)
{
    this->ui->name->setText(QString(urlInfo.name.c_str()));
    this->ui->tag->setText(QString(urlInfo.tag.c_str()));
    this->ui->link->setText(QString(urlInfo.url.c_str()));
}


UrlInfo UrlInfoItemWidget::getUrlInfo()
{
    UrlInfo info;
    info.name = this->ui->name->text().toStdString();
    info.url = this->ui->link->text().toStdString();
    info.tag = this->ui->tag->text().toStdString();
    return info;
}




void UrlInfoItemWidget::on_pushButton_clicked()
{
    emit deleteItem(this->ui->link->text());
}

